<#assign ctx=request.contextPath />
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>随笔添加</title>
    <script src="${ctx}/js/jquery.min.js"></script>
    <script src="${ctx}/layui/layui.js"></script>
    <link href="${ctx}/layui/css/layui.css" rel="stylesheet">
    <link rel="stylesheet" href="${ctx}/css/ztree/metro/ztree.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/css/treeselect.css" media="all"/>
    <style>
        .layui-form-item {
            width: 500px;
        }

        .ztree {
            height: 260px;
            overflow-y: auto;
        }
    </style>
</head>
<body>

<div class="site-text site-block" style=" border:1px solid #ccc; padding:20px; margin:20px;">
    <form class="layui-form">
        <input hidden name="id" value="${project.id}">
        <div class="layui-form-item">
            <label class="layui-form-label">项目名</label>
            <div class="layui-input-block">
                <input type="text" name="name" value="${project.name}" lay-verify="required" class="layui-input"/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">负责人</label>
            <div class="layui-input-block">
                <select name="uname">
                <#list userList as user>
                    <option value="${user.id}" <#if user.id==project.uid>selected</#if>>${user.nickName}</option>
                </#list>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">IDE</label>
            <div class="layui-input-block">
                <input type="text" name="ide" value="${project.ide}" lay-verify="required" class="layui-input"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">技术框架</label>
            <div class="layui-input-block">
                <input type="text" name="framework" value="${project.framework}" class="layui-input"/>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
            <#--<a onclick="window.history.go(-1);" class="layui-btn layui-btn-primary">返回</a>-->
                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formDemo">修改</button>
            </div>
        </div>
    </form>
</div>


<script>

    layui.use(['layer', 'form'], function () {
        var layer = layui.layer;
        var form = layui.form;
        form.on('submit(formDemo)',
                function (data) {
                    var obj = data.field;
                    check(obj);
                    console.log(obj);
                    $.ajax({
                        url: "${ctx}/updateProject",
                        type: "post",
                        data: obj,
                        success: function (res) {
                            if (res.status == 0) {
                                layer.msg(res.msg, {icon: 6, time: 600}, function () {
                                    location.href = '${ctx}/projectList'
                                });
                            } else {
                                layer.msg(res.msg, {icon: 5})
                            }
                        }
                    });
                    return false
                });

    });

</script>
</body>
</html>
